home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / JZCHRSTR.ASM < prev    next >
Assembly Source File  |  1989-04-09  |  2KB  |  65 lines

  1. Comment *
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │jzchrstr                                     │
  4. │Concatenate a character onto the end of a string adding the null character  │
  5. │                                         │
  6. │Parms                                         │
  7. │  wstr = string to concatenate to                         │
  8. │  wch    = char to concatenate                             │
  9. │                                         │
  10. │Synopsis:                                     │
  11. │                                         │
  12. │   strcpy(wstr,"hello ther");                                               │
  13. │   wch = 'e'                                                                │
  14. │   jzchrstr(wstr,wch);                              │
  15. └────────────────────────────────────────────────────────────────────────────┘
  16. *
  17.  
  18. ;=============================================================================
  19. ;                    Data
  20. ;=============================================================================
  21.  
  22. DGROUP    group    _DATA
  23. _DATA    segment word public 'DATA'
  24.     assume    ds:DGROUP
  25.  
  26.     ; Your Data goes here . . .
  27.  
  28. _DATA    ends
  29.  
  30. ;=============================================================================
  31. ;                   Code
  32. ;=============================================================================
  33.  
  34.     assume cs:_text
  35. _text    segment public byte 'code'
  36.     PUBLIC _jzchrstr
  37.  
  38. _jzchrstr       proc near
  39.  
  40.     push bp             ; save base of stack
  41.     mov bp,sp            ; establish stack frame
  42.  
  43.     push di             ; save MS-C's Register vars
  44.  
  45.     mov di,[bp].4            ; get address of dest string
  46.     mov bx,[bp].6            ; get character value to concatenate
  47.     xor bh,bh            ; set high byte
  48.     xor ax,ax            ; search for a zero byte
  49.     mov cx,0FFFFh            ; allow 64k max str length
  50.     repnz scasb
  51.     dec di
  52.     mov byte ptr [di],bl        ; get char into string
  53.     inc di
  54.     mov byte ptr [di],bh        ; get zero into last byte
  55.  
  56.     pop di                ; Restore MS-C's Register vars
  57.  
  58.     mov sp,bp            ; restore stack pointer
  59.     pop  bp             ; and base of stack
  60.     ret                ; return to caller
  61.  
  62. _jzchrstr       endp
  63. _text    ends
  64. end
  65.